<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>title</title>
</head>
<body>
    <script>
        function randomString(n=0){
        var str = 'zxcvbnmasdfghjklqwertyuiopZXCVBNMASDFGHJKLQWERTYUIOP1234567890'
        var temp = '';
        k = str.length;
        for(var i=0;i<n;i++){
            //生成不大于str长度的随机数
            temp += str.charAt(Math.floor(Math.random() * k))
            /*charAt(index)方法获取index位置的字符，位置从О开始计算;
            Math.floor()方法获取小于或等于x的最大整数，即向下取整;
            Math.random()方法获取大于或等于0.0且小于1.0的随机值。*/
        }
        return temp;
    }
    console.log(randomString(3));
</script>
</body>
</html>